package com.web.dao;

import com.web.entity.HotExpertBean;
import com.web.entity.UserExpert;
import com.web.entity.UserExpertInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserExpertMapper {
    @Delete({
        "delete from APP_USER_EXPERT",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into APP_USER_EXPERT (user_id, expert_class, ",
        "realname, sex, mobile, ",
        "email, edu, city, ",
        "work_experience, professional_skill, ",
        "auth_status, create_time, ",
        "modify_time)",
        "values (#{userId,jdbcType=VARCHAR}, #{expertClass,jdbcType=VARCHAR}, ",
        "#{realname,jdbcType=VARCHAR}, #{sex,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, ",
        "#{email,jdbcType=VARCHAR}, #{edu,jdbcType=VARCHAR}, #{city,jdbcType=VARCHAR}, ",
        "#{workExperience,jdbcType=VARCHAR}, #{professionalSkill,jdbcType=VARCHAR}, ",
        "#{authStatus,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{modifyTime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(UserExpert record);

    int insertSelective(UserExpert record);

    @Select({
        "select",
        "id, user_id, expert_class, realname, sex, mobile, email, edu, city, work_experience, ",
        "professional_skill, auth_status, create_time, modify_time",
        "from APP_USER_EXPERT",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    UserExpert selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(UserExpert record);

    @Update({
        "update APP_USER_EXPERT",
        "set user_id = #{userId,jdbcType=VARCHAR},",
          "expert_class = #{expertClass,jdbcType=VARCHAR},",
          "realname = #{realname,jdbcType=VARCHAR},",
          "sex = #{sex,jdbcType=VARCHAR},",
          "mobile = #{mobile,jdbcType=VARCHAR},",
          "email = #{email,jdbcType=VARCHAR},",
          "edu = #{edu,jdbcType=VARCHAR},",
          "city = #{city,jdbcType=VARCHAR},",
          "work_experience = #{workExperience,jdbcType=VARCHAR},",
          "professional_skill = #{professionalSkill,jdbcType=VARCHAR},",
          "auth_status = #{authStatus,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(UserExpert record);

    UserExpert findUserExpert(@Param("key") String key,@Param("value") String value);

    List<HotExpertBean> getHotExpert(@Param("userId") String userId);
}